package net.pinnoocle.playadminpc.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.pinnoocle.playcommon.response.BaseResult;
import net.pinnoocle.playdao.entity.admin.homepage.ActiveUserTopVo;
import net.pinnoocle.playdao.entity.admin.homepage.TodayDataVo;
import net.pinnoocle.playdao.entity.admin.homepage.TopShopByGroup;
import net.pinnoocle.playdao.entity.admin.homepage.TotalDataVo;
import net.pinnoocle.playdao.entity.shopPc.TopScriptListVo;
import net.pinnoocle.playdao.entity.shopPc.master.TopMasterListVo;
import net.pinnoocle.playservice.service.impl.AdminAnalysisService;
import net.pinnoocle.playservice.service.impl.MasterServiceImpl;
import net.pinnoocle.playservice.service.impl.ScriptServiceImpl;
import net.pinnoocle.playservice.service.impl.ShopServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ye
 * @Description
 * @create 2021-12-06 10:54
 */
@RestController
@RequestMapping("/home")
@Api(tags = "首页")

public class HomePageController {

    @Autowired
    AdminAnalysisService adminAnalysisService;
    @Autowired
    ShopServiceImpl shopService;
    @Autowired
    ScriptServiceImpl scriptService;
    @Autowired
    MasterServiceImpl masterService;

    @GetMapping("getTotalData")
    @ApiOperation("数据总览")
    public BaseResult<TotalDataVo> getTotalData(){
        return new BaseResult<TotalDataVo>().ok(adminAnalysisService.getTotalData());
    }

    @GetMapping("getTodayData")
    @ApiOperation("实时概况")
    public BaseResult<TodayDataVo> getTodayData(){
        return new BaseResult<TodayDataVo>().ok(adminAnalysisService.getTodayData());
    }

    @GetMapping("topShopByGroup")
    @ApiOperation("热门店铺排行--组局数降序")
    public BaseResult<List<TopShopByGroup>> topShopByGroup(@RequestParam("offset") Integer offset){
        return new BaseResult<List<TopShopByGroup>>().ok(shopService.topShopByGroup(offset));
    }

    @GetMapping("topScriptByGroup")
    @ApiOperation("剧本排行 type 0 平台剧本 1 店铺剧本")
    public BaseResult<List<TopScriptListVo>> topScriptByGroup(@RequestParam("type") Integer type,
                                                              @RequestParam("offset") Integer offset){
        return new BaseResult<List<TopScriptListVo>>().ok(scriptService.topScriptByGroup(type,offset));
    }

    @GetMapping("topMaster")
    @ApiOperation("店家DM排行")
    public BaseResult<List<TopMasterListVo>> topMaster(@RequestParam("offset") Integer offset){
        return new BaseResult<List<TopMasterListVo>>().ok(masterService.topMasterPlatform(offset));
    }

    @GetMapping("activeUserTop")
    @ApiOperation("活跃用户排行榜")
    public BaseResult<ActiveUserTopVo> activeUserTop(@RequestParam("offset") Integer offset){
        return new BaseResult<ActiveUserTopVo>().ok(adminAnalysisService.activeUserTop(offset));
    }
}
